package com.ctrl.riveradministrator.mvp.view.activity.bulletin;

import android.content.Context;
import android.content.pm.ActivityInfo;
import android.os.Message;
import android.support.constraint.ConstraintLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

import com.ctrl.riveradministrator.R;
import com.ctrl.riveradministrator.base.BaseActivity;
import com.ctrl.riveradministrator.base.BasePresenter;
import com.ctrl.riveradministrator.mvp.model.Bulletin;
import com.ctrl.riveradministrator.mvp.view.weight.RiverInfoDialog;

public class FullScreenActivity extends BaseActivity {

    private TextView qjhz, qjjz, xjhz, xjjz, cjhz, lxbm, hzzz,sheng,sjhz,t2,t3,t4,
            ztmb, ndmb, jddh, fzhd1, fzrw1, fzhd2, fzrw2, fzhd3, lxr, title;
    private ConstraintLayout shiL;
    private ImageView close;
    private ConstraintLayout content;
    private Bulletin bulletin;
    private RiverInfoDialog riverInfoDialog;

    @Override
    protected void initParams(Bundle parms) {
        bulletin = (Bulletin) getIntent().getSerializableExtra("bulletin");
    }

    @Override
    protected int bindLayout() {
        setmAllowFullScreen(true);
        return R.layout.activity_full_screen;
    }

    @Override
    protected void initView(View view) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        riverInfoDialog = new RiverInfoDialog(this);
        content = findViewById(R.id.content);
        close = findViewById(R.id.close);
        title = findViewById(R.id.t1);
        shiL = findViewById(R.id.shi);
        sheng = findViewById(R.id.t12_sheng);
        sjhz = findViewById(R.id.shengjihezhang_shi);
        qjhz = findViewById(R.id.shijihezhang);
        t2 = findViewById(R.id.t2);
        t3 = findViewById(R.id.t3);
        t4 = findViewById(R.id.t4);
        qjjz = findViewById(R.id.shijijingzhang);
        xjhz = findViewById(R.id.xiangjihezhang);
        xjjz = findViewById(R.id.xiangjijingzhang);
        cjhz = findViewById(R.id.cunjihezhang);
        lxbm = findViewById(R.id.lianxibumen);
        hzzz = findViewById(R.id.hezhangzhize);
        ztmb = findViewById(R.id.zongtimubiao);
        ndmb = findViewById(R.id.niandumubiao);
        jddh = findViewById(R.id.jiandudianhua);
        fzhd1 = findViewById(R.id.fuzehedao1);
        fzrw1 = findViewById(R.id.fuzerenwu1);
        fzhd2 = findViewById(R.id.fuzehedao2);
        fzrw2 = findViewById(R.id.fuzerenwu2);
        lxr = findViewById(R.id.lianxiren);

        switch (bulletin.getGradeId()) {
            case "1"://省
                title.setText("山东省省级河湖河长公示牌");
                sjhz.setText(bulletin.getProRiverJob());
                qjhz.setText(bulletin.getShiRiverName());
                qjjz.setText(bulletin.getShiWarnName());
                xjhz.setText(bulletin.getRiverName());
                cjhz.setText(bulletin.getTownRiverName());
                break;
            case "2"://市
                title.setText("德州市市级河湖河长公示牌");
                sheng.setVisibility(View.GONE);
                sjhz.setVisibility(View.GONE);
                qjhz.setText(bulletin.getShiRiverName());
                qjjz.setText(bulletin.getShiWarnName());
                xjhz.setText(bulletin.getRiverName());
                cjhz.setText(bulletin.getTownRiverName());
                break;
            case "3"://区县
                sheng.setVisibility(View.GONE);
                sjhz.setVisibility(View.GONE);
                t2.setVisibility(View.GONE);
                qjhz.setVisibility(View.GONE);
                qjjz.setVisibility(View.GONE);
                t3.setVisibility(View.GONE);
                title.setText("德州市陵城区区级河湖河长公示牌");
                xjhz.setText(bulletin.getRiverName());
                cjhz.setText(bulletin.getTownRiverName());
                break;
            case "4"://乡镇
                sheng.setVisibility(View.GONE);
                sjhz.setVisibility(View.GONE);
                t2.setVisibility(View.GONE);
                qjhz.setVisibility(View.GONE);
                qjjz.setVisibility(View.GONE);
                t3.setVisibility(View.GONE);
                t4.setVisibility(View.GONE);
                xjhz.setVisibility(View.GONE);
                title.setText("德州市陵城区" + bulletin.getPsignAreaName() + "乡级河湖河长公示牌");
                cjhz.setText(bulletin.getTownRiverName());
                break;
        }
        try{
            lxbm.setText(bulletin.getTelephone());
            jddh.setText(bulletin.getSuperviseTele());
            ztmb.setText(bulletin.getTarget());
            hzzz.setText(bulletin.getDuty());
            ndmb.setText(bulletin.getYearTarget());
            fzhd1.setText(bulletin.getShiRiverAdminName());
            fzrw1.setText(bulletin.getShiRiverJob());
            fzhd2.setText(bulletin.getRiverAdminName());
            fzrw2.setText(bulletin.getRiverJob());
            lxr.setText(bulletin.getContacts());
            if (bulletin.getTarget().length() > 20) {
                ztmb.setText(bulletin.getTarget().substring(0, 20) + "...");
            }
            if (bulletin.getDuty().length() > 20) {
                hzzz.setText(bulletin.getDuty().substring(0, 20) + "...");
            }
            if (bulletin.getYearTarget().length() > 20) {
                ndmb.setText(bulletin.getYearTarget().substring(0, 20) + "...");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    @Override
    protected void doBusiness(Context mContext) {

    }

    @Override
    protected void widgetClick(View view) {
        switch (view.getId()) {
            case R.id.niandumubiao:
                riverInfoDialog.showText(bulletin.getYearTarget());
                break;
            case R.id.hezhangzhize:
                riverInfoDialog.showText(bulletin.getDuty());
            case R.id.zongtimubiao:
                riverInfoDialog.showText(bulletin.getTarget());
                break;
            case R.id.close:
                finish();
                break;
        }
    }

    @Override
    protected void setListener() {
        ztmb.setOnClickListener(this);
        hzzz.setOnClickListener(this);
        ndmb.setOnClickListener(this);
        content.setOnClickListener(this);
        close.setOnClickListener(this);
    }

    @Override
    public void handleMessage(Message message, int what) {

    }

    @Override
    protected BasePresenter createPresenter() {
        return null;
    }
}
